/*
*
*
*
*
*
*/

package Offer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author c10mjn
 */
public class OfferList implements Iterable<Offer>{
    private final List<Offer> offerList;
    
    public OfferList(){
        this.offerList = Collections.synchronizedList(new ArrayList<Offer>());
    }
    
    public void addOffer(Offer offerObj){
        this.offerList.add(offerObj);
    }

    @Override
    public Iterator<Offer> iterator() {
        return this.offerList.iterator();
    }
    
    public boolean hasOffer(){
        return this.offerList.listIterator().hasNext();
    }
    
    public Offer getNext(){
        if (this.hasOffer()) {
            return this.offerList.listIterator().next();
        } else {
            throw new ArrayIndexOutOfBoundsException("Stepped to far");
        }
    }   
    
    public Integer getNoOffers(){
        return this.offerList.size();
    }
    
    public List<Offer> getList(){
        return this.offerList;
    }

    

   
    
}
